﻿using DailyApp.WPF.Models;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DailyApp.WPF.ViewModels
{
    /// <summary>
    /// 设置页视图模型
    /// </summary>
    class SettingsUCViewModel : BindableBase
    {
        //创建区域管理
        private readonly IRegionManager regionManager;


        /// <summary>
        /// 构造函数
        /// </summary>
        public SettingsUCViewModel(IRegionManager _regionManager)
        {
            //取出依赖注入服务
            regionManager = _regionManager;

            //委托命令实现
            NavigateCmd = new DelegateCommand<LeftMenuModel>(NavigateFunc);

            CreatLeftMenusList();
        }


        #region 初始化左侧选项

        /// <summary>
        /// 左侧选项集合属性
        /// </summary>
        private List<LeftMenuModel> leftMenusList;

        public List<LeftMenuModel> LeftMenusList
        {
            get { return leftMenusList; }
            set
            {
                leftMenusList = value;
                RaisePropertyChanged();
            }
        }

        //初始化左侧选项方法
        private void CreatLeftMenusList()
        {
            LeftMenusList = new List<LeftMenuModel>();

            LeftMenusList.Add(new LeftMenuModel() { Icon = "Palette", MenuName = "个性化", ViewName = "PersonalUC" });
            LeftMenusList.Add(new LeftMenuModel() { Icon = "Cog", MenuName = "系统设置", ViewName = "SystemSettingsUC" });
            LeftMenusList.Add(new LeftMenuModel() { Icon = "Information", MenuName = "关于更多", ViewName = "AboutUsUC" });
        }

        #endregion

        #region 切换页


        //切换页面的命令
        public DelegateCommand<LeftMenuModel> NavigateCmd { get; set; }

        private void NavigateFunc(LeftMenuModel item)
        {
            regionManager.RequestNavigate("SettingsRegion",item.ViewName);
        }

        #endregion
    }
}
